# coding: utf8
# datetime: 2021-04-11
# 题目地址: https://leetcode-cn.com/problems/ugly-number-ii/


class Solution:
    def nthUglyNumber(self, n: int) -> int:
        count = 0
        seen = set()
        seen.add(1)
        while True:
            tmp_min = min(seen)
            count += 1
            if count == n:
                return tmp_min
            seen.remove(tmp_min)
            for num in [2,3,5]:
                seen.add(tmp_min*num)


a = Solution()
print(a.nthUglyNumber(10))
